//
//  HNLogicPosition.m
//  HeroNuts
//
//  Created by Gelford on 11-4-27.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import "HNLogicPosition.h"

@implementation HNLogicPosition

@synthesize position = position_;


- (id)initWithPoint:(CGPoint)point
{
    if ((self = [super init])) {
        position_ = point;

    }
    return self;
}

-(CGFloat) x
{
    return position_.x;
}

-(CGFloat) y
{
    return position_.y;
}

+ (CGPoint)distanceInPixelsFrom:(CGPoint)start to:(CGPoint)end
{
    CGPoint distance;
    int deltaY = (int)(end.y-start.y);
    int deltaX = (int)(end.x-start.x);
    distance.y = deltaY*VERTICALDISTANCE;
    //deltaY is an odd number
    if (deltaY&1) 
    {
        if (((int)start.y)&1) 
        {
            distance.x = deltaX*HORIZONTALDISTANCE+HORIZONTALDISTANCE/2;
        }
        else
        {
            distance.x = deltaX*HORIZONTALDISTANCE-HORIZONTALDISTANCE/2;
        }
    }
    //deltaY is an even number
    else
    {
        distance.x = deltaX*HORIZONTALDISTANCE;
    }
    return distance;
}


@end
